home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_sh-utils.idb / usr / freeware / catman / u_man / cat1 / expr.Z / expr
Encoding:
Text File  |  1998-05-21  |  5.8 KB  |  200 lines

  1. /xlv1/freeware/1998.May/sh-utils/1.16b/sh-utils-1.16b.diffbuild/man
  2.  
  3.  
  4.  
  5.      EEEEXXXXPPPPRRRR((((1111))))         FFFFSSSSFFFF ((((GGGGNNNNUUUU SSSShhhheeeellllllll    UUUUttttiiiilllliiiittttiiiieeeessss))))           EEEEXXXXPPPPRRRR((((1111))))
  6.  
  7.  
  8.  
  9.      NNNNAAAAMMMMEEEE
  10.       expr - evaluate expressions
  11.  
  12.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.       eeeexxxxpppprrrr expression...
  14.       eeeexxxxpppprrrr {--help,--version}
  15.  
  16.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  17.       This documentation is    no longer being    maintained and may be
  18.       inaccurate or    incomplete.  The Texinfo documentation is now
  19.       the authoritative source.
  20.  
  21.       This manual page documents the GNU version of    eeeexxxxpppprrrr.  eeeexxxxpppprrrr
  22.       evaluates an expression and writes the result    on its
  23.       standard output.  Each token of the expression must be a
  24.       separate argument.  Operands are either numbers or strings.
  25.       Strings are not quoted for eeeexxxxpppprrrr, though you may need to
  26.       quote    them to    protect    them from the shell.  eeeexxxxpppprrrr coerces
  27.       anything appearing in    an operand position to an integer or a
  28.       string depending on the operation being applied to it.
  29.  
  30.       The operators    (in order of increasing    precedence) are:
  31.  
  32.       |    Yields its first    argument if it is neither null nor 0,
  33.            otherwise its second argument.  This is the usual `or'
  34.            operation.
  35.  
  36.       &    Yields its first    argument if neither argument is    null
  37.            or 0, otherwise 0.
  38.  
  39.       <  <=     =  ==    !=  >=    >
  40.            Compare their arguments and return 1 if the relation is
  41.            true, 0 otherwise.  (== is a synonym for    =.)  eeeexxxxpppprrrr
  42.            tries to    coerce both arguments to numbers and do    a
  43.            numeric comparison; if it fails when trying to coerce
  44.            either argument it then does a lexicographic
  45.            comparison.
  46.  
  47.       +  - Perform arithmetic operations.  Both arguments are
  48.            coerced to numbers; an error occurs if this cannot be
  49.            done.
  50.  
  51.       *  /    %
  52.            Perform arithmetic operations (`%' is the remainder
  53.            operation, as in    C).  Both arguments are    coerced    to
  54.            numbers;    an error occurs    if this    cannot be done.
  55.  
  56.       :    Perform pattern matching.  Its arguments    are coerced to
  57.            strings and the second one is considered    to be a
  58.            regular expression, with    a `^' implicitly added at the
  59.            beginning.  The first argument is then matched against
  60.            this regular expression.     If the    match succeeds and
  61.  
  62.  
  63.  
  64.      Page 1                         (printed 5/18/98)
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.      EEEEXXXXPPPPRRRR((((1111))))         FFFFSSSSFFFF ((((GGGGNNNNUUUU SSSShhhheeeellllllll    UUUUttttiiiilllliiiittttiiiieeeessss))))           EEEEXXXXPPPPRRRR((((1111))))
  72.  
  73.  
  74.  
  75.            part of the string is enclosed in `\(' and `\)',    that
  76.            part is the value of the    : expression; otherwise    an
  77.            integer whose value is the number of characters matched
  78.            is returned.  If    the match fails, the :    operator
  79.            returns the null    string if `\(' and `\)'    are used,
  80.            otherwise 0.  Only one `\(' and `\)' pair can be    used.
  81.  
  82.       In addition, the following keywords are recognized:
  83.  
  84.       mmmmaaaattttcccchhhh    _s_t_r_i_n_g _r_e_g_e_x
  85.            An alternative way to do    pattern    matching.  This    is the
  86.            same as ``_s_t_r_i_n_g    :::: _r_e_g_e_x''.
  87.  
  88.       ssssuuuubbbbssssttttrrrr _s_t_r_i_n_g    _p_o_s_i_t_i_o_n _l_e_n_g_t_h
  89.            Return the substring of _s_t_r_i_n_g beginning    at _p_o_s_i_t_i_o_n
  90.            with length at most _l_e_n_g_t_h.  If either _p_o_s_i_t_i_o_n or
  91.            _l_e_n_g_t_h is negative or non-numeric, return a null
  92.            string.
  93.  
  94.       iiiinnnnddddeeeexxxx    _s_t_r_i_n_g _c_h_a_r_a_c_t_e_r-_c_l_a_s_s
  95.            Return the first    position in _s_t_r_i_n_g where the first
  96.            character in _c_h_a_r_a_c_t_e_r-_c_l_a_s_s was    found.    If no
  97.            character in _c_h_a_r_a_c_t_e_r-_c_l_a_s_s is found in    _s_t_r_i_n_g,    return
  98.            0.
  99.  
  100.       lllleeeennnnggggtttthhhh _s_t_r_i_n_g
  101.            Return the length of _s_t_r_i_n_g.
  102.  
  103.       Parentheses are used for grouping in the usual manner.  The
  104.       keywords cannot be used as strings.
  105.  
  106.     OOOOPPPPTTTTIIIIOOOONNNNSSSS
  107.       When GNU eeeexxxxpppprrrr    is invoked with    exactly    one argument, the
  108.       following options are    recognized:
  109.  
  110.       --_h_e_l_p
  111.            Print a usage message on    standard output    and exit
  112.            successfully.
  113.  
  114.       --_v_e_r_s_i_o_n
  115.            Print version information on standard output then exit
  116.            successfully.
  117.  
  118.      EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS
  119.       To add 1 to the shell    variable _a:
  120.  
  121.            a=`expr $a + 1`
  122.  
  123.       The following    may be used to print the non-directory part of
  124.       the file name    stored in variable _a (the value    in _a need not
  125.       contain `/'):
  126.  
  127.  
  128.  
  129.  
  130.      Page 2                         (printed 5/18/98)
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.      EEEEXXXXPPPPRRRR((((1111))))         FFFFSSSSFFFF ((((GGGGNNNNUUUU SSSShhhheeeellllllll    UUUUttttiiiilllliiiittttiiiieeeessss))))           EEEEXXXXPPPPRRRR((((1111))))
  138.  
  139.  
  140.  
  141.            expr $a : '.*/\(.*\)' '|' $a
  142.  
  143.       Note the quoted shell    metacharacters.
  144.  
  145.       eeeexxxxpppprrrr returns the following exit status:
  146.  
  147.       0 if the expression is neither null nor 0,
  148.       1 if the expression is null or 0,
  149.       2 for    invalid    expressions.
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.      Page 3                         (printed 5/18/98)
  197.  
  198.  
  199.  
  200.